package com.example.xpvideo.Controller;

import com.example.xpvideo.entity.PageResult;
import com.example.xpvideo.entity.ResponseResult;
import com.example.xpvideo.entity.req.ReplyList;
import com.example.xpvideo.entity.req.SecondReplyList;
import com.example.xpvideo.entity.req.UpdateReq;
import com.example.xpvideo.entity.res.GoodsCommentsRes;
import com.example.xpvideo.entity.res.PhpSecondComment;
import com.example.xpvideo.entity.res.PhpVideoCommentRes;
import com.example.xpvideo.entity.res.SecondComments;
import com.example.xpvideo.service.PhpVideoCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 洪俊新
 * @date : 2021/9/14 16:16
 * @description:
 */
@RestController
@RequestMapping("/back/videocomment")
public class PhpVideoCommentController {
    @Autowired
    private PhpVideoCommentService phpVideoCommentService;


    /**
     * 获取一级评论列表
     *
     * @param replyList the reply list
     * @return response result
     * @throws Exception the exception
     */
    @GetMapping("/list")
    public ResponseResult<PageResult<List<PhpVideoCommentRes>>> replyList(
            @Validated ReplyList replyList) throws Exception {
        return phpVideoCommentService.replyList(replyList);
    }

    /**
     * 获取某一评论下的完整二级评论列表
     *
     * @param secondReplyList the second reply list
     * @return the response result
     * @throws Exception the exception
     */
    @GetMapping("/list/second")
    public ResponseResult<PageResult<List<PhpSecondComment>>> secondReplyList(
            @Validated SecondReplyList secondReplyList) throws Exception {
        return phpVideoCommentService.secondReplyList(secondReplyList);
    }
    /**
     * 删除评论
     *
     * @param updateReq the updateReq
     * @return the response result
     * @throws Exception the exception
     */
    @PostMapping("/delete")
    public ResponseResult<Object> deleteComment(@RequestBody @Validated
                                                        UpdateReq updateReq) throws Exception{
        return phpVideoCommentService.deleteComment(updateReq);
    }
}
